type AppendArgument1<Fn, T> = Fn extends (...args: infer P) => infer R
  ? (...arg: P) => R // (...arg: P) => R 等价于 (...args: [...P]) => R  就是 (a: number, b: string) => R
  : never;

// Fn extends (...args: infer R) => infer T ? (...args: [...R, A]) => T : never

type Fn = (a: number, b: string) => number;
type A1 = AppendArgument1<Fn, boolean>; // 还是 Fn 没有改变

// 给函数追加一个参数
type AppendArgument2<Fn, T> = Fn extends (...args: infer P) => infer R
  ? (...arg: [...P, T]) => R // 等价于 (a: number, b: string, x: T) => R
  : never;

type A2 = AppendArgument2<Fn, boolean>; // (a: number, b: string, x: boolean) => number

const obj = {
  name: "cjx",
  age: 18,
  info: "",
};
obj;
type ObjType = typeof obj;
const t: ObjType = {
  name: "",
  age: 0,
  info: "",
};
sum(obj);

function sum(obj: ObjType) {}

export {};
